import {$post} from "../utils/request.js"
export default{
	namespaced : true,//开启命名空间后，访问所有说行都要带模块名
	state(){
		return{
			userInfo:null
		}
	},
	mutations:{
		initInfo(state,info){
			state.userInfo=info
			uni.setStorage({
				key:'userinfo',
				data:info
			})
		}
	},
	actions:{
		userLoginAct(context,info){
			uni.request({
				url: 'https://se1zcx96.lc-cn-n1-shared.com/1.1/login',
				method: 'POST',
				header: {
					'X-LC-Id': 'SE1zCX96WxeRzvNyhm5rdVMI-gzGzoHsz',
					'X-LC-Key': '92BR3Wc2daMq9gUWib15J6Q5',
					'Content-Type': 'application/json'
				},
				data: info,
				success: (res) => {		
					console.log(res);
					 let {code}=res.data
					 if(code){
						 let title =code===211 ? '账号不存在' : '密码错误'
						 uni.showToast({
							 title,
							icon:"none"
						 })
						 return
					 }
					 context.commit('initInfo',res.data)
					
			
				}
			})
		}
	}
}